package com.zwz.resp.bid;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import java.math.BigDecimal;
import java.util.*;

@Data
public class BiddingResponse {
    private Integer stat;
    private Integer total;

    @JsonProperty("data")
    private List<BiddingProject> projects;

    @Data
    public static class BiddingProject {
        @JsonProperty("biddingId")
        private String id;

        @JsonProperty("infoType")
        private String type;

        private String title;

        @JsonFormat(pattern = "yyyy-MM-dd")
        private Date publishDate;

        @JsonProperty("projectRegion")
        private ProjectRegion region;

        @JsonProperty("projectAmount")
        private BigDecimal amount;

        @JsonProperty("purchasingBidderList")
        private List<PurchasingBidder> bidders = new ArrayList<>();

        @JsonProperty("subjectMatterList")
        private List<String> subjectMatters = new ArrayList<>();

        // 数据清洗方法
        @JsonIgnore
        public String getCleanTitle() {
            return title.replaceAll("[^\\u4e00-\\u9fa5a-zA-Z0-9]", " ").trim();
        }
    }

    @Data
    public static class ProjectRegion {
        private String province;
        private String city;
        private String district;  // 可能不存在的字段
    }

    @Data
    public static class PurchasingBidder {
        @JsonProperty("nameId")
        private String bidderId;

        private String name;

        @JsonProperty("oeEnterpriseType")
        private EnterpriseType enterpriseType;
    }

    @Data
    public static class EnterpriseType {
        @JsonProperty("first")
        private List<String> primaryCategory = new ArrayList<>();

        @JsonProperty("second")
        private List<String> secondaryCategory = new ArrayList<>();
    }


    public Integer getStat() {
        return this.stat;
    }

    public void setStat(Integer stat) {
        this.stat = stat;
    }

    public Integer getTotal() {
        return this.total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public List<BiddingProject> getProjects() {
        return this.projects;
    }

    public void setProjects(List<BiddingProject> projects) {
        this.projects = projects;
    }


}